let app = getApp();

Component({
    /**
     * 组件的属性列表
     */
    properties: {
        backIcon: {
            type: Boolean,
            value: false
        },
        title: {
            type: String,
            value: "nav title"
        },
        weather: {
            type: Boolean,
            value: false
        },
        weatherNum: {
            type: String,
            value: ''
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        lang: null,

        // 状态栏高度
        statusBarHeight: wx.getStorageSync('statusBarHeight') + 'px',

        // 导航栏高度
        navigationBarHeight: wx.getStorageSync('navigationBarHeight') + 'px',

        // 胶囊按钮高度
        menuButtonHeight: wx.getStorageSync('menuButtonHeight') + 'px',

        // 导航栏和状态栏高度
        navigationBarAndStatusBarHeight:
            wx.getStorageSync('statusBarHeight') +
            wx.getStorageSync('navigationBarHeight') +
            'px'

    },
    lifetimes: {
        attached: function() {
            this.setData({ lang: app.globalData.lang })
        },
    },

    /**
     * 组件的方法列表
     */
    methods: {
        // 扫码
        onScan(){
            wx.scanCode({
                success: (res) => {
                    console.log("扫码: ", res)
                }
            })
        },
        
        previous() {
            wx.navigateBack({
                delta: 1,
                fail: err => {
                    console.log("err: ", err);
                    wx.navigateTo({
                      url: '/pages/index/index',
                    })
                }
            })
        }
    }
})
